package com.example.tagsdemo.conf;

import com.example.tagsdemo.directive.MyTagDirective;
import com.example.tagsdemo.directive.StudentListDirective;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;


@Configuration
public class TagConfig {

    @Autowired
    private freemarker.template.Configuration configuration;

    @Autowired
    protected MyTagDirective myTagDirective;

    @Autowired
    protected StudentListDirective studentListDirective;
    /**
     * 添加自定义标签
     */
    @PostConstruct
    public void setSharedVariable() {
        /*
         * 向freemarker配置中添加共享变量;
         */
        configuration.setSharedVariable("myTag", myTagDirective);
        configuration.setSharedVariable("studentList", studentListDirective);
    }
}
